import type { RouteRecordRaw } from "vue-router";
const icons = import.meta.glob('@/assets/aside/*.png', { eager: true }) as Record<string, { default: string }>;
const iconMap = Object.fromEntries(
  Object.entries(icons).map(([key, value]) => [
    key.match(/\/([^/]+)\.png$/)?.[1] || '', 
    value.default
  ])
);
export const Layout = () => import("@/views/Layout/index.vue")
export const staticRoutes: Array<RouteRecordRaw> = [
    {
      path: "/login",
      name: "Login",
      component: () => import("@/views/login/index.vue"),
      meta: {
        isShow: false,
        title:'登录'
      },
    },
    {
      path: "/404",
      meta: { title: "404", isShow: false },
      component: () => import("@/views/404/index.vue"),
    },
  /*   {
      path: '/',
      component: Layout,
      redirect: "/home",
      meta: { title: "", icon: "", isShow: false },
      children: [
        {
          path: "/home",
          name: "home",
          component: () => import("@/views/home/index.vue"),
          meta: { title: "首页",  isShow: true,icon:iconMap['home'] }
        },
      ],
    }, */
    {
      path: "/dataScreen",
      name: "DataScreen",
      component: () => import("@/views/dataScreen/index.vue"),
      meta: {
        isShow: false,
        title: '数据大屏'
      }
    },
]
/**
 * @动态路由
 */
export const allAsyncRoutes = [
  {
    path:"/",
    name:"RootNodeManagement",
    redirect:'/nodeManagement',
    component:Layout,
    meta:{
      title:'',
      isShow:false,
    },
    children:[
      {
        path:"/nodeManagement",
        name:"nodeManagement",
        component: () => import('@/views/nodeManagement/index.vue'),
        meta:{
          title:'节点管理',
          isShow:true,
          icon:iconMap['nodeManagement']
        } 
      },
      {
        path:"/nodeManagement/nodeDetail",
        name:"nodeDetail",
        component: () => import('@/views/nodeManagement/nodeDetail/index.vue'),
        meta:{
          title:'节点详情',
          isShow:false,
          icon:iconMap['nodeManagement']
        }
      }
    ]
  },
  {
    path:"/",
    name:"RootDeployPlatform",
    redirect:'/deployPlatform',
    component:Layout,
    meta:{
      title:'',
      isShow:false,
    },
    children:[
      {
        path:"/deployPlatform",
        name:"deployPlatform",
        component: () => import('@/views/deployPlatform/index.vue'),
        meta:{
          title:'部署平台',
          isShow:true,
          icon:iconMap['deployPlatform']
        }
      },
      {
        path:"/deployPlatform/deploymentManagement",
        name:"deploymentManagement",
        component: () => import('@/views/deployPlatform/deploymentManagement/index.vue'),
        meta:{
          title:'部署管理',
          isShow:false,
          icon:iconMap['deployPlatformDetail']
        }
      },
      {
        path:"/deployPlatform/deploymentDetail",
        name:"deploymentDetail",
        component: () => import('@/views/deployPlatform/deploymentDetail/index.vue'),
        meta:{
          title:'部署详情',
          isShow:false,
          icon:iconMap['deployPlatformDetail']
        }
      }
    ]
  },
  {
    path:"/",
    name:"RootTestPlatform",
    redirect:'/testPlatform',
    component:Layout,
    meta:{
      title:'',
      isShow:false,
    },
    children:[
      {
        path:"/testPlatform",
        name:"testPlatform",
        component: () => import('@/views/testPlatform/index.vue'),
        meta:{
          title:'测试平台',
          isShow:true,
          icon:iconMap['testPlatform']
        }
      },
      {
        path:"/faultTest",
        name:"faultTest",
        component: () => import('@/views/testPlatform/faultTest/index.vue'),
        meta:{
          title:'故障测试',
          isShow:false,
          icon:iconMap['testPlatform']
        }
      }
    ]
  },
  // 仿真平台
  {
    path:"/",
    name:"RootSimulationPlatform",
    redirect:'/simulationPlatform',
    component:Layout,
    meta:{
      title:'',
      isShow:false,
    },
    children:[
      {
        path:"/simulationPlatform",
        name:"simulationPlatform",
        component: () => import('@/views/simulationPlatform/index.vue'),
        meta:{
          title:'仿真平台',
          isShow:true,
          icon:iconMap['simulationPlatform']
        }
      }
    ]
  }
]
/***
 * @任意路由
 */
export const anyRouter = [
  {
    path: "/:pathMatch(.*)*",
    name: 'Any',
    meta: { title: "任意路由", isShow: false },
    redirect: "/404",
  },
]